# $Id: PKGBUILD 61038 2011-12-20 20:32:11Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=arm-wince-cegcc-libstdcppdll
pkgver=0.59.1
pkgrel=1
_prefix=/opt/cegcc
pkgdesc="CE GCC bundle - cross compilation tools for WinCE"
arch=('any')
license=(GPL)
url="http://cegcc.sf.net"
depends=('arm-wince-cegcc-cegccdll')
makedepends=('arm-wince-cegcc-gcc' 'arm-wince-cegcc-newlib' 'arm-wince-cegcc-importlibs'
	     'arm-wince-cegcc-w32api')
groups=('cegcc')
options=(!libtool !strip)
source=(http://arch.p5n.pp.ru/~sergej/dl/cegcc-$pkgver.tar.bz2)
md5sums=('5e3c1098abdf8e5db2a3518ee3578b4b')

build() {
  export PATH=$_prefix/bin:$PATH
  export TARGET=arm-wince-cegcc
  unset CFLAGS
  unset CXXFLAGS
  unset LDFLAGS
  unset MAKEFLAGS

  cd $srcdir/cegcc/src/

  mkdir build-gcc || true
  cd build-gcc

if [ $NOEXTRACT -ne 1 ]; then
  ../gcc-4.4.0/configure \
	--prefix=${_prefix} \
	--exec-prefix=${_prefix} \
	--bindir=${_prefix}/bin \
	--target=arm-wince-cegcc \
	--build=$CARCH \
	--host=$CARCH \
	--disable-nls \
	--includedir=${_prefix}/include \
	--with-gcc \
	--with-gnu-ld \
	--with-gnu-as \
	--enable-threads=win32 \
	--enable-languages=c,c++ \
	--disable-win32-registry \
	--disable-multilib \
	--disable-interwork \
	--without-newlib \
	--enable-checking \
	--with-headers \
	--disable-libssp
fi

  make

  #
  # libstdc++
  #
  cd $srcdir/cegcc/src/cegcc/libstdc++

  sed -i 's#.*unwind-sjlj_s.o#\t\t../../build-gcc/arm-wince-cegcc/libgcc/unwind-sjlj_s.o#' Makefile

  make

  mkdir -p $pkgdir${_prefix}/arm-wince-cegcc/lib
  make PREFIX=$pkgdir/${_prefix} install

  rm -f $pkgdir${_prefix}/arm-wince-cegcc/lib/device
  find $pkgdir/${_prefix} -type f -name \*.a -exec arm-wince-cegcc-ranlib {} \;
}
